<?php
include_once ("koneksi.php");

class ModelContactUs {

	public function __construct (){
			$this-> koneksi = new Koneksi();
		} //<!--end of __construct--> 
	  
	public function getContactUs (){
		$this->koneksi->_connect();
		$query = "select * from contactus";
		
		$result = mysql_query($query);
		while ($data = mysql_fetch_array($result)) {
			$array[$data['ID_CONTACTUS']]=new ContactUs($data['ID_CONTACTUS'], $data['ID_USER'], 
			$data['NAMAPENGIRIM'], $data['EMAILPENGIRIM'], $data['JUDULCONTACTUS'], $data['ISICONTACTUS']);
		}
		$this->koneksi->_close();
		if (!empty($array))
		{
			return $array;
		}
	}
	
	public function addContactUs($id_user, $namapengirim, $emailpengirim, $judulcontactus, $isicontactus)
	{
		$this->koneksi->_connect();
		$query = mysql_query
		("INSERT INTO `contactus` (id_contactus, id_user, namapengirim, emailpengirim, judulcontactus, isicontactus) 
		VALUES ('', '$id_user', '$namapengirim', '$emailpengirim', '$judulcontactus', '$isicontactus');");
		$this->koneksi->_close();
		return true;
	}
	
	public function  deleteContactUs($id_contactus){
		$this->koneksi->_connect();
		$query = mysql_query("DELETE FROM `contactus` WHERE ID_CONTACTUS = '$id_contactus';");	
		$this->koneksi->_close();
		return true;
	}
}
?>
	

	
<?php
	
class ContactUs {
	public $id_contactus;
	public $id_user;
	public $namapengirim;
	public $emailpengirim;
	public $judulcontactus;
	public $isicontactus;
	
	public function __construct($id_contactus, $id_user, $namapengirim, $emailpengirim, $judulcontactus, $isicontactus)  
    {  
        $this->id_contactus = $id_contactus;
	    $this->id_user = $id_user;
	    $this->namapengirim = $namapengirim;
		$this->emailpengirim = $emailpengirim;
		$this->judulcontactus = $judulcontactus;
		$this->isicontactus = $isicontactus;
    } 
}
?>